package RKUjava.datastructures;
import java.io.Serializable;

/** The RKUDoubleChainWrapper implements a wrapper for objects not implementing
    the RKUDoubleChainLink interface. If you add elements not implementing the
    interface they will be wrapped using this class.
*/
public class RKUDoubleChainWrapper implements Serializable, RKUDoubleChainLink
{
  /** Pointer to next element.
      @serial
  */
  public Object rkudoublechainnext;
  /** Pointer to previous element.
    @serial
  */
  public Object rkudoublechainprev;
  
  /** The wrapped object.
    @serial
  */
  public Object theobject;

  /** Create a new wrapper for the objevt.
      @param obj the object to wrap.
  */
  public RKUDoubleChainWrapper(Object obj)
    {
      theobject = obj;
      rkudoublechainnext = null;
      rkudoublechainprev = null;
    };

  /** Get the next element on the double chain. */
  public Object getDoubleChainNext()
    {
      return rkudoublechainnext;
    };

  /** Get the previous element on the double chain. */
  public Object getDoubleChainPrev()
    {
      return rkudoublechainprev;
    };
  
  /** Set the next element on the double chain. */
  public void setDoubleChainNext(Object next)
    {
      rkudoublechainnext = next;
    };
  
  /** Set the previous element on the double chain. */
  public void setDoubleChainPrev(Object prev)
    {
      rkudoublechainprev = prev;
    };

  public String toString()
    {
      return theobject.toString();
    }
}
